package com.java.escape.dlcopy;

import java.io.*;

/**
 * @ClassName Student
 * @Description TODO
 * @Author wyp
 * @Date 2023/9/15 15:29
 * @Version 1.0
 */
public class Student implements Cloneable, Serializable {
    private String name;
    private Integer age;

    private Education education;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Education getEducation() {
        return education;
    }

    public void setEducation(Education education) {
        this.education = education;
    }

        @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
    //序列化实现深拷贝
//    @Override
//    public Student clone() {
//        Student student = null;
//        try {
//            ByteArrayOutputStream bos = new ByteArrayOutputStream();
//            ObjectOutputStream oos = new ObjectOutputStream(bos);
//            oos.writeObject(this);
//
//            //将流序列化成对象
//            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
//            ObjectInputStream ois = new ObjectInputStream(bis);
//            student = (Student) ois.readObject();
//        } catch (IOException | ClassNotFoundException e) {
//            throw new RuntimeException(e);
//        }
//        return student;
//    }

//    @Override
//    public String toString() {
//        return "Student{" +
//                "name='" + name + '\'' +
//                ", age=" + age +
//                ", education=" + education +
//                '}';
//    }
}
